package com.zzt.mybatis.service;

import com.zzt.mybatis.mapper.UserInfoMapper;
import com.zzt.mybatis.model.UserInfo;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description
 * User: panda
 * Date: 2025-03-05
 * Time: 9:56
 */
@Service
public class UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    public UserInfo queryUserByUserNameAndPassword(String username, String password) {
        List<UserInfo> userInfos = userInfoMapper.selectByNameAndPassword(password,username);
        if(userInfos != null && userInfos.size() >= 1){
            return userInfos.get(0);
        }
        return null;
    }

    public List<UserInfo> getAllUser() {
        return userInfoMapper.selectAll();
    }

    public UserInfo getUserInfoById(Integer id) {
        return userInfoMapper.selectAllById(id);
    }
}
